//
//  NuanxinXiangqingVC.m
//  New
//
//  Created by 才诗琦 on 16/1/22.
//  Copyright © 2016年 www.lanou3g.com. All rights reserved.
//

#import "NuanxinXiangqingVC.h"
#import "SliderView-Prefix.pch"
@interface NuanxinXiangqingVC ()
@property(nonatomic, retain)UIWebView * wv;
@property(nonatomic, retain)NSMutableArray *dataArr;
@end

@implementation NuanxinXiangqingVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor whiteColor];
    
    
    //左按钮
    self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(fanHui:)] autorelease];
    self.navigationController.navigationBar.translucent = NO;
    //创建WebView
   self.wv = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 375, 667)];
    
    NSLog(@"%@", self.str);
    [AFNModel GETWithHandler:self.str completion:^(id result) {
//  解析数据
        
        NSDictionary *dic = result[@"body"];
        
        NSString *str1 = dic[@"text"];
        NSLog(@"%@",str1);
        NSString *str = [str1 stringByAppendingString:@"<head><style>img{max-width:320px !important;}</style></head>%@"];
        [self.wv loadHTMLString:str baseURL:[NSURL URLWithString:_str]];
        
    
    }];
           //添加父视图
    [self.view addSubview:self.wv];
    
    //管理内存
    [self.wv release];
   
    
}

//- (void)webViewDidFinishLoad:(UIWebView *)webView
//{
//    [AFNModel GETWithHandler:self.str completion:^(id result) {
//        NSString *currentURL = [webView stringByEvaluatingJavaScriptFromString:result[@"body"][@"text"]];

//        2、获取页面title：
//        [plain] view plaincopy
        
//        NSString *title = [_wv stringByEvaluatingJavaScriptFromString:@"document.title"];
//        
//        NSString *js_result = [webView stringByEvaluatingJavaScriptFromString:@"document.getElementsByName('q')[0].value='朱祁林';"];
//        NSString *js_result2 = [webView stringByEvaluatingJavaScriptFromString:@"document.forms[0].submit(); "];
//        这样就实现了在google搜索关键字：“朱祁林”的功能。
//        5、插入js代码
//        上面的功能我们可以封装到一个js函数中，将这个函数插入到页面上执行，代码如下：
//        [plain] view plaincopy
        
        //        NSString *title = [_wv stringByEvaluatingJavaScriptFromString:result[@"body"][@"text"] ];
    
    
    
//    }];
//}


//按钮实现方法
- (void)fanHui:(UIBarButtonItem *)fanhui
{
    [self.navigationController popViewControllerAnimated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
